{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "plt.rcParams[\"font.sans-serif\"] = [\"SimHei\"]\n",
    "plt.rcParams[\"axes.unicode_minus\"] = False\n",
    "pd.options.display.max_rows = 20"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Stock</th>\n",
       "      <th>Date</th>\n",
       "      <th>Time</th>\n",
       "      <th>Timestamp</th>\n",
       "      <th>LastPx</th>\n",
       "      <th>HighPx</th>\n",
       "      <th>LowPx</th>\n",
       "      <th>OpenPx</th>\n",
       "      <th>PreClosePx</th>\n",
       "      <th>TotalVolumeTrade</th>\n",
       "      <th>...</th>\n",
       "      <th>BidPx2</th>\n",
       "      <th>BidPx3</th>\n",
       "      <th>BidPx4</th>\n",
       "      <th>BidPx5</th>\n",
       "      <th>BidVol1</th>\n",
       "      <th>BidVol2</th>\n",
       "      <th>BidVol3</th>\n",
       "      <th>BidVol4</th>\n",
       "      <th>BidVol5</th>\n",
       "      <th>BuyOrSell</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>IC2009</td>\n",
       "      <td>20200120</td>\n",
       "      <td>92900300</td>\n",
       "      <td>1.579484e+09</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5435.4</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>5366.0</td>\n",
       "      <td>5350.0</td>\n",
       "      <td>5343.0</td>\n",
       "      <td>5333.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>IC2009</td>\n",
       "      <td>20200120</td>\n",
       "      <td>93000300</td>\n",
       "      <td>1.579484e+09</td>\n",
       "      <td>5388.0</td>\n",
       "      <td>5388.0</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5435.4</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>5371.4</td>\n",
       "      <td>5370.0</td>\n",
       "      <td>5366.0</td>\n",
       "      <td>5350.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>B</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>IC2009</td>\n",
       "      <td>20200120</td>\n",
       "      <td>93000800</td>\n",
       "      <td>1.579484e+09</td>\n",
       "      <td>5388.0</td>\n",
       "      <td>5388.0</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5435.4</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>5371.4</td>\n",
       "      <td>5370.0</td>\n",
       "      <td>5366.0</td>\n",
       "      <td>5350.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>IC2009</td>\n",
       "      <td>20200120</td>\n",
       "      <td>93001300</td>\n",
       "      <td>1.579484e+09</td>\n",
       "      <td>5388.0</td>\n",
       "      <td>5388.0</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5435.4</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>5371.4</td>\n",
       "      <td>5370.0</td>\n",
       "      <td>5366.0</td>\n",
       "      <td>5350.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>IC2009</td>\n",
       "      <td>20200120</td>\n",
       "      <td>93001800</td>\n",
       "      <td>1.579484e+09</td>\n",
       "      <td>5388.0</td>\n",
       "      <td>5388.0</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5387.8</td>\n",
       "      <td>5435.4</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>5371.4</td>\n",
       "      <td>5370.0</td>\n",
       "      <td>5366.0</td>\n",
       "      <td>5350.0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>N</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 35 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    Stock      Date      Time     Timestamp  LastPx  HighPx   LowPx  OpenPx  \\\n",
       "0  IC2009  20200120  92900300  1.579484e+09  5387.8  5387.8  5387.8  5387.8   \n",
       "1  IC2009  20200120  93000300  1.579484e+09  5388.0  5388.0  5387.8  5387.8   \n",
       "2  IC2009  20200120  93000800  1.579484e+09  5388.0  5388.0  5387.8  5387.8   \n",
       "3  IC2009  20200120  93001300  1.579484e+09  5388.0  5388.0  5387.8  5387.8   \n",
       "4  IC2009  20200120  93001800  1.579484e+09  5388.0  5388.0  5387.8  5387.8   \n",
       "\n",
       "   PreClosePx  TotalVolumeTrade    ...      BidPx2  BidPx3  BidPx4  BidPx5  \\\n",
       "0      5435.4                 1    ...      5366.0  5350.0  5343.0  5333.0   \n",
       "1      5435.4                 2    ...      5371.4  5370.0  5366.0  5350.0   \n",
       "2      5435.4                 2    ...      5371.4  5370.0  5366.0  5350.0   \n",
       "3      5435.4                 2    ...      5371.4  5370.0  5366.0  5350.0   \n",
       "4      5435.4                 2    ...      5371.4  5370.0  5366.0  5350.0   \n",
       "\n",
       "   BidVol1  BidVol2  BidVol3  BidVol4  BidVol5  BuyOrSell  \n",
       "0        1        1        1        1        1          N  \n",
       "1        1        1        1        1        1          B  \n",
       "2        1        1        1        1        1          N  \n",
       "3        1        1        1        1        1          N  \n",
       "4        1        1        1        1        1          N  \n",
       "\n",
       "[5 rows x 35 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "with open(r\"C:\\Users\\新田草\\Desktop\\正仁量化\\data\\IC2009_test.csv\") as f:\n",
    "    data = pd.read_csv(f)\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3748025"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_data = data.iloc[:4000, :]\n",
    "test_data.to_csv(r\"C:\\Users\\新田草\\Desktop\\正仁量化\\data\\IC2009_test.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
